测试链接：https://leetcode.cn/problems/tvdfij/
class Solution {
public:
    int pivotIndex(vector<int>& nums) {
        int n = nums.size();
        // [0 1 8 11 17 22 28]
        // [0 2 3 2]
        vector<int> dp(n+1, 0);
        for(int i = 1; i <= n; i++)
        {
            dp[i] = dp[i-1] + nums[i-1];
        }

        for(int i = 0; i < n; i++)
        {
            int leftnum = dp[i];
            int rightnum = dp[n] - dp[i+1];//第三种情况
            if(leftnum == rightnum)
            {
                return i;
            }
        }

        return -1;
    }
};